﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.EquipmentManagement;
using Digitalmes.Model.FactoryManagement;

namespace Digitalmes.Model.EquipmentManagement
{
    /// <summary>
    /// 设备台账
    /// </summary>
	[Table("Equipment")]

    [Display(Name = "_Model.Equipment")]
    public class Equipment : BasePoco,IPersistPoco,ITenant
    {

        [Key]
        [Display(Name = "_Model._Equipment._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }



        [Display(Name = "_Model._LineShift._Line")]
        [Comment("产线")]
        public long? LineId { get; set; }

        public ProductionLine Line { get; set; }    

        [Display(Name = "_Model._Equipment._EquipName")]
        [StringLength(255, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("设备名称")]
        public string EquipName { get; set; }
        [Display(Name = "_Model._Equipment._IpAddress")]
        [Comment("网络地址")]
        [RegularExpression("(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)$")]
        public string IpAddress { get; set; }
        [Display(Name = "_Model._Equipment._Port")]
        [Comment("端口")]
        public int Port { get; set; }=0;    
        [Display(Name = "_Model._Equipment._Actvie")]
        [Comment("激活")]
        public bool? Actvie { get; set; }
        [Display(Name = "_Model._Equipment._DriverType")]
        [Comment("驱动类型")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public DriverTypeEnum? DriverType { get; set; }
        [Display(Name = "_Model._Equipment._Aux_1")]
        [Comment("备用1")]
        public string Aux_1 { get; set; }
        [Display(Name = "_Model._Equipment._Aux_2")]
        [Comment("备用2")]
        public string Aux_2 { get; set; }
        [Display(Name = "_Model._Equipment._EquipCode")]
        [Comment("设备编号")]
        public string EquipCode { get; set; }
        [Display(Name = "_Model._Equipment._EquipType")]
        [Comment("设备类型")]
        public EquipTypeEnum? EquipType { get; set; }
        [Display(Name = "_Model._Equipment._Manufactor")]
        [Comment("生产厂家")]
        public string Manufactor { get; set; }
        [Display(Name = "_Model._Equipment._SpotType")]
        [Comment("点检模式")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public EquipSpotCheckEnum? SpotType { get; set; }
        [Display(Name = "_Model._EquipmentTag._Equipment")]
        [InverseProperty("Equipment")]
        public List<EquipmentTag> EquipmentTag_Equipment { get; set; }
        [Display(Name = "_Model._EquipAlarmRecord._Equipment")]
        [InverseProperty("Equipment")]
        public List<EquipmentAlarmItem> EquipAlarm_Equipment { get; set; }
        [Display(Name = "_Model._Equipment._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }


        //[Display(Name = "_Model._Equipment._Equipment")]
        //[Comment("ProductionLine")]
        //public List<EquipmentProductionLine> EquipmentProductionLines { get; set; }

        [Display(Name = "_Model._Equipment._DriverGroup")]
        [Comment("驱动组")]
        public string DriverGroup { get; set; }
        public List<EquipmentSerial> EquipmentSerial_Equipment { get; set; }
    }

}
